package cn.edu.dzkd.software.controller;

import cn.edu.dzkd.software.pojo.Department;
import cn.edu.dzkd.software.pojo.Role;
import cn.edu.dzkd.software.service.DepartmentService;
import cn.edu.dzkd.software.service.RoleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/department")
public class DepartmentController {

    @Resource
    private DepartmentService departmentService;

    @RequestMapping(value = "/selectDepartments", method = RequestMethod.GET)
    public Map<String, Object> selectDepartments(@RequestParam int page,
                                           String departmentName,
                                           String departCreateTime) {
        return departmentService.selectDepartments(page, departmentName, departCreateTime);
    }

    @RequestMapping(value = "/selectAllDepartments", method = RequestMethod.GET)
    public Map<String, Object> selectAllDepartments() {
        return departmentService.selectAllDepartments();
    }

    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public Map<String, Object> insert(@RequestBody Department department) {
        return departmentService.insert(department);
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Map<String, Object> update(@RequestBody Department department) {
        return departmentService.update(department);
    }

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Map<String, Object> delete(@RequestParam Integer id) {
        return departmentService.delete(id);
    }
}
